package com.luban.ziya.sync;

import org.openjdk.jol.info.ClassLayout;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * Created By ziya
 * 2020/9/14
 */
public class SyncTest_10 {

    static SyncTest_10 obj = new SyncTest_10();

    public static void main(String args[]) throws InterruptedException{

        SyncTest_10 c = new SyncTest_10();

        new Thread(){
            public void run() {
                try {
                    c.add(2);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }.start();

        int sum = c.add(1);


        System.out.println("dddddddddddddddddddd");
// System.gc();



    }

    public int add(int a) throws InterruptedException{
        synchronized(this){
            int b = 1;
            int c = a + b;
            Thread.sleep(100000000000l);
        }
        return 0;
    }
}
